package com.chixing.ih.module.programmer.other;

import com.chixing.ih.util.DateUtil;

import java.util.*;

/**
 * Created with IntelliJ IDEA.
 * Description:
 *
 * @version 1.0
 * @Author MasterYan
 * @Date 2020/10/13
 * Time: 19:02
 */

public class DateList {

    public static List<String> getDateList() {
        List<String> dates = new ArrayList<>();
        Calendar ca1 = Calendar.getInstance();//得到一个Calendar的实例
        ca1.setTime(new Date()); //设置时间为当前时间
        String date1 = DateUtil.formatDate(ca1.getTime(), "yyyy");

        Calendar ca2 = Calendar.getInstance();//得到一个Calendar的实例
        ca2.setTime(new Date()); //设置时间为当前时间
        ca2.add(Calendar.YEAR, -1);
        String date2 = DateUtil.formatDate(ca2.getTime(), "yyyy");

        Calendar ca3 = Calendar.getInstance();//得到一个Calendar的实例
        ca3.setTime(new Date()); //设置时间为当前时间
        ca3.add(Calendar.YEAR, -2);
        String date3 = DateUtil.formatDate(ca3.getTime(), "yyyy");

        Calendar ca4 = Calendar.getInstance();//得到一个Calendar的实例
        ca4.setTime(new Date()); //设置时间为当前时间
        ca4.add(Calendar.YEAR, -3);
        String date4 = DateUtil.formatDate(ca4.getTime(), "yyyy");

        Calendar ca5 = Calendar.getInstance();//得到一个Calendar的实例
        ca5.setTime(new Date()); //设置时间为当前时间
        ca5.add(Calendar.YEAR, -4);
        String date5 = DateUtil.formatDate(ca5.getTime(), "yyyy");

        Calendar ca6 = Calendar.getInstance();//得到一个Calendar的实例
        ca6.setTime(new Date()); //设置时间为当前时间
        ca6.add(Calendar.YEAR, -5);
        String date6 = DateUtil.formatDate(ca6.getTime(), "yyyy");
        dates.add(date6);
        dates.add(date5);
        dates.add(date4);
        dates.add(date3);
        dates.add(date2);
        dates.add(date1);

        return dates;


    }


}
